SELECT	*
into	LX_PROCESSO_LOG_temp
FROM	LX_PROCESSO_LOG
WHERE	STATUS = '5'
and		PROCESSO in ('LX_LJ_GERA_MOVIMENTO_ECF','LX_LF_LOJA_CONTROLE_FISCAL_IMPOSTO')


sp_helptext LX_PROCESSOS

commit

select	b.*
from	LX_PROCESSO_LOG a
join	LX_PROCESSO_LOG_temp b
on		a.SEQUENCIA = b.SEQUENCIA
and		a.COMANDO = b.COMANDO
and		a.STATUS = 5
and		(b.STATUS = 1 or b.STATUS = 9)


/*atualiza tabela original*/
-- update	a
set		a.status = b.status, a.data_log = b.data_log, a.log_processo = b.log_processo, a.data_processado = b.data_processado
from	LX_PROCESSO_LOG a
join	LX_PROCESSO_LOG_temp b
on		a.SEQUENCIA = b.SEQUENCIA
and		a.COMANDO = b.COMANDO
and		a.STATUS = 5
and		(b.STATUS = 1 or b.STATUS = 9)




drop table LX_PROCESSO_LOG_temp

rafael???


